{{ header }}
<div id="account-comment" class="container">
  {{ helper.breadcrumb(breadcrumbs) }}
  <div class="row">
    {{ column_left }}
    {% if column_left and column_right %}
      {% set class = 'col-sm-6' %}
    {% elseif column_left or column_right %}
      {% set class = 'col-sm-9' %}
    {% else %}
      {% set class = 'col-sm-12' %}
    {% endif %}
    <div id="content" class="{{ class }}">
      {{ content_top }}
      <h2>{{ heading_title }}</h2>
      <div class="row">
        <!-- filter -->
        <div id="filter-product" class="col-md-3 col-md-push-9 col-sm-12 hidden-sm hidden-xs">
          <div class="panel panel-default">
            <div class="panel-heading">
              <h3 class="panel-title"><i class="fa fa-filter"></i> {{ text_filter }}</h3>
            </div>
            <div class="panel-body">
              <div class="form-group">
                <label class="control-label" for="input-order-id">{{ entry_order_id }}</label>
                <input type="text" name="filter_order_id" value="{{ filter_order_id }}" placeholder="{{ entry_order_id }}" id="input-order-id" class="form-control" />
              </div>
              <div class="form-group">
                <label class="control-label" for="input-rating">{{ entry_rating }}</label>
                <select name="filter_rating" id="input-rating" class="form-control">
                  <option value="">{{ entry_rating_select }}</option>
                  <option value="0" {% if(filter_rating == 0) %} selected {% endif %}>{{ entry_zero }}</option>
                  <option value="1" {% if(filter_rating == 1) %} selected {% endif %}>{{ entry_one }}</option>
                  <option value="2" {% if(filter_rating == 2) %} selected {% endif %}>{{ entry_two }}</option>
                  <option value="3" {% if(filter_rating == 3) %} selected {% endif %}>{{ entry_three }}</option>
                  <option value="4" {% if(filter_rating == 4) %} selected {% endif %}>{{ entry_four }}</option>
                  <option value="5" {% if(filter_rating == 5) %} selected {% endif %}>{{ entry_five }}</option>
                </select>
              </div>
              <div class="form-group">
                <label class="control-label" for="input-date-created">{{ entry_date_created }}</label>
                <input type="text" name="filter_date_created" value="{{ filter_date_created }}" placeholder="{{ entry_date_created }}" id="input-date-created" class="form-control" readonly="readonly"/>
              </div>
              <div class="form-group">
                <label class="control-label" for="input-date-modified">{{ entry_date_modify }}</label>
                <input type="text" name="filter_date_modified" value="{{ filter_date_modified }}" placeholder="{{ entry_date_modify }}" id="input-date-modified" class="form-control" readonly="readonly"/>
              </div>

              <div class="form-group">
                <label class="control-label" for="input-status">{{ entry_status }}</label>
                <select name="filter_status" id="input-status" class="form-control">
                  <option value="">{{ text_select_status }}</option>
                  <option value="0">{{ text_disabled }}</option>
                  <option value="1">{{ text_enabled }}</option>
                </select>
              </div>
              <div class="form-group text-right">
                <button type="button" id="button-filter" class="btn btn-default"><i class="fa fa-filter"></i> {{ button_filter }}</button>
              </div>
            </div>
          </div>
        </div>
        <!-- filter end -->
        <!-- table list -->
        <div class="col-md-9 col-md-pull-3 col-sm-12">
          <div class="panel panel-default">
            <div class="panel-heading">
              <h3 class="panel-title"><i class="fa fa-list"></i> {{ text_list }}</h3>
            </div>
            <div class="panel-body">
              {% if success %}
                <div class="alert alert-success alert-dismissible"><i class="fa fa-check-circle"></i> {{ success }}
                  <button type="button" class="close" data-dismiss="alert">&times;</button>
                </div>
              {% endif %}
              <form action="{{ delete }}" method="post" enctype="multipart/form-data" id="form-product">
                <div class="table-responsive">
                  <table class="table table-bordered table-hover">
                    <thead>
                      <tr>
                        <td></td>
                        <td class="text-center">{{ column_name }}</td>
                        <td class="text-center">{{ column_model }}</td>
                        <td class="text-center">{{ column_rating }}</td>
                        <td class="text-center">{{ column_date_created }}</td>
                        <td class="text-center">{{ column_date_modified }}</td>
                        <td class="text-center">{{ column_action }}</td>
                      </tr>
                    </thead>
                    <tbody>
                    {% if(comments) %}
                      {% for comment in comments %}
                        <tr>
                          <td class="text-center">{{ comment.id }}</td>
                          <td class="text-center">{{ comment.product_name }}</td>
                          <td class="text-center">{{ comment.product_model }}</td>
                          <td class="text-center">{{ comment.rating }}</td>
                          <td class="text-center">{{ comment.date_created }}</td>
                          <td class="text-center">{{ comment.date_modified }}</td>
                          <td class="text-center">
                            <a class="btn btn-primary" href="{{ comment.edit }}"><i class="fa fa-pencil"></i></a>
                            <a class="btn btn-danger del-comment" href="javascript:;" link="{{ comment.delete }}"><i class="fa fa-trash-o"></i></a>
                          </td>
                        </tr>
                      {% endfor %}
                    {% else %}
                      <tr>
                        <td colspan="7" class="text-center">{{ text_no_results }}</td>
                      </tr>
                    {% endif %}
                    </tbody>
                  </table>
                </div>
              </form>
              <div class="row">
                <div class="col-sm-6 text-left">{{ pagination }}</div>
                <div class="col-sm-6 text-right">{{ results }}</div>
              </div>
            </div>
          </div>
        </div>
        <!-- table list end -->
      </div>
      {{ content_bottom }}
    </div>
    {{ column_right }}
  </div>
</div>
<script type="text/javascript">
  showDate('input-date-created');
  showDate('input-date-modified');
  $(document).on('click', '#button-filter', function () {
    var url = '';
    var filter_order_id = $('input[name="filter_order_id"]').val();
    if (filter_order_id) {
      url += '&filter_order_id=' + encodeURIComponent(filter_order_id);
    }
    var filter_rating = $('select[name="filter_rating"]').find('option:selected').val();
    if (filter_rating) {
      url += '&filter_rating=' + encodeURIComponent(filter_rating);
    }
    var filter_date_created = $('input[name="filter_date_created"]').val();
    if (filter_date_created) {
      url += '&filter_date_created=' + encodeURIComponent(filter_date_created);
    }
    var filter_date_modified = $('input[name="filter_date_modified"]').val();
    if (filter_date_modified) {
      url += '&filter_date_modified=' + encodeURIComponent(filter_date_modified);
    }

    var filter_status = $('select[name=\'filter_status\']').val();
    if (filter_status !== '') {
      url += '&filter_status=' + encodeURIComponent(filter_status);
    }
    location = 'index.php?route=account/comment' + url;
  });

  $(document).on('click', '.del-comment', function () {
    var link = $(this).attr('link');
    var confirm_layer = layer.confirm('{{ text_confirm }}', {
      btn: ['{{ text_sure }}','{{ text_cancel }}'] //按钮
    }, function(){
      layer.close(confirm_layer);
      window.location.href = link;
    }, function(){

    });
  });
</script>
{{ footer }}